import {
  Entity,
  PrimaryGeneratedColumn,
  Column,
  ManyToOne,
  JoinColumn,
  OneToOne,
} from 'typeorm';
import { Group } from 'src/modules/group/entities/group.entity';
import { EventToPlayer } from 'src/modules/event-to-player/entities/event-to-player.entity';

@Entity()
export class GroupPlayerScore {
  @PrimaryGeneratedColumn()
  id?: number;

  @Column({ name: 'fk_group_id' })
  groupId: number;

  @ManyToOne(() => Group, (group) => group.groupPlayerScores)
  @JoinColumn({ name: 'fk_group_id' })
  group?: Partial<Group>;

  @Column({ name: 'fk_player_id' })
  playerId: number;

  @OneToOne(() => EventToPlayer)
  @JoinColumn({ name: 'fk_player_id' })
  player?: EventToPlayer;

  @Column()
  registrationIndex?: string;

  @Column({ default: 0 })
  winTeamMatchCount?: number;

  @Column({ default: 0 })
  loseTeamMatchCount?: number;

  @Column({ default: 0 })
  winMatchCount?: number;

  @Column({ default: 0 })
  loseMatchCount?: number;

  @Column({ name: 'eliminationPosition' })
  eliminationPosition?: number;

  @Column({ default: 0 })
  winRallyCount?: number;

  @Column({ default: 0 })
  loseRallyCount?: number;

  @Column({ default: 0 })
  winGameCount?: number;

  @Column({ default: 0 })
  loseGameCount?: number;

  @Column({ default: 0 })
  ranking?: number;
}
